package com.boss.salary.service.impl;

import com.boss.common.entity.PageDTO;
import com.boss.framework.dto.PaginationDTO;
import com.boss.salary.dao.IQuerySalaryDataDao;
import com.boss.salary.entity.QuerySalaryData;
import com.boss.salary.service.IQuerySalaryDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class QuerySalaryDataServiceImpl implements IQuerySalaryDataService {


    /**
     * 引入日志框架常量
     */
    private final static Logger logger = LoggerFactory.getLogger(PersonExtServiceImpl.class);

    @Autowired
    private IQuerySalaryDataDao dao;
    /**
     * 获取工资支付数据
     * @param paginationDTO
     * @param queryParam
     * @return
     */
    @Override
    public PageDTO queryPayrollDataPage(PaginationDTO paginationDTO, Map<String, Object> queryParam,List<String> childrenIds) {
        QuerySalaryData querySalaryData = dao.queryTotalWages(queryParam,childrenIds);
        querySalaryData.setNO("合计");
        //月结工资查询分页
        List<QuerySalaryData> wage = dao.getPayrollDataPage(paginationDTO, queryParam,childrenIds);
        if (wage.size() > 0) {
            wage.add(0, querySalaryData);
        }
        //月结工资查询分页total
        int total = dao.getPayrollDataTotal(queryParam,childrenIds);
        PageDTO<QuerySalaryData> pageDTO = new PageDTO<>();
        pageDTO.setRows(wage);
        pageDTO.setTotal(total);
        return pageDTO;
    }

    @Override
    public List<QuerySalaryData> getPayrollData(Map<String, Object> queryParam,List<String> childrenIds) {
        QuerySalaryData querySalaryData = dao.queryTotalWages(queryParam,childrenIds);
        querySalaryData.setNO("合计");
        List<QuerySalaryData> wage =dao.getPayrollData(queryParam,childrenIds);
        return  wage;
    }
}
